package com.example.dataTypes;

import java.util.ArrayList;
import java.util.List;

public class MovingAverage {
	private List<Float> ls;
	private int stackSize = 30;

	public MovingAverage() {
		ls = new ArrayList<Float>();
	}

	public int getStackSize() {
		return stackSize;
	}

	public void setStackSize(int stackSize) {
		this.stackSize = stackSize;
	}

	public void AddElement(float newElement) {
		while (ls.size() >= stackSize) {
			ls.remove(0);
		}
		ls.add(newElement);
	}

	public float getAvrage() {
		float avg = 0;
		for (int a = 0; a < ls.size(); a++) {
			avg += ls.get(a);
		}
		avg = avg / ls.size();
		return avg;
	}

}
